#include <XnCppWrapper.h>
#include "CFugue.h"
#include <vector>
#include <gl/GLU.h>
#include <math.h>
#include <sstream>


#ifdef _DEBUG
#define new DEBUG_NEW
#endif


CFugue::CFugue()
{
	mChord = (Chords)C;
	minor = false;
}

CFugue::~CFugue()
{
	ClearPoints();
}

void CFugue::EvalPoints()
{
	//Just deal with keys represented as integers 0-7, potentially as a structure with octave attached. 
	//		(or, -8 to -1, 8 to 14... etc)... better way?
	//Save them to mClusters. 

	//When adding a note to a cluster, don't add it if it's already there. Alt: add a different octave, then stop.
}

static enum k {
	A, B, C, D, E, F, G
};

std::string duration(int i)
{
	//Convert the integer to the proper duration string (4 = 4/16, = quarter note)
	double perc = (double)i/16.;
	std::ostringstream s; 
	s << perc;
	return s.str();	
}

void CFugue::Play()
{
	//Before this section, represent notes as 1-8. Translate them to here, based on the chord key as the 
	//  starting note. Ex: in CMaj, 1 = C. 
	/*std::string mStr = "K["; //The actual music string, starting with the key signature
	mStr += mCd; //the key signature, as a string
	mStr += "] ";

	
	//int newColKey = ((int)curCol + 1) % 12;
	//curCol = static_cast<Chords>(newColKey);

	//int start = 0; //Figuring out the conversion to enum k, based on the chord we have

	for (int i=0; i<15; i++)
	{
		//Process each of the various channels

		//TODO: allow for mid-measure changing key????????

		//Set which voice/channel it's on
		mStr += "V";
		std::ostringstream s;
		s << i;
		mStr += s.str();
		mStr += " "; //Always end current segment with a space

		if (i > 0)
		{
			mStr += "R/";
			mStr += duration(i); 
			//Add the rest here to offset when the current cluster is to be played
		}

	}*/
	std::string mStr = "CMajwww";

	mPlayer.PlayAsync(mStr);

}